package org.lq.dlz.service.impl;

import java.util.List;

import org.apache.commons.codec.digest.DigestUtils;
import org.lq.dlz.dao.UserDao;
import org.lq.dlz.dao.impl.UserDaoImpl;
import org.lq.dlz.entity.User;
import org.lq.dlz.service.UserService;

/**
 * @author 丁苗
 * @组名 狂奔的肉夹馍
 * @version创建时间 2019年6月14日上午9:55:24
 */
public class UserServiceImpl implements UserService {

	private UserDao userDao = new UserDaoImpl();
	@Override
	public boolean addUser(User user) {
		user.setRole(0);
		user.setStatus(0);
		user.setPassword(DigestUtils.md5Hex(user.getPassword()+user.getUsername()+user.getPhone()));
		return userDao.addUser(user)>0;
	}

	@Override
	public boolean deleteUser(int id) {
		return userDao.deleteUser(id)>0;
	}

	@Override
	public List<User> findUser() {
		return userDao.findUser();
	}

	@Override
	public boolean updateUser(User user) {
		return userDao.updateUser(user)>0;
	}

	@Override
	public User login(String username, String password) {
		return userDao.login(username, password);
	}

	@Override
	public User getUserByUsername(String username) {
		return userDao.getUserByUsername(username);
	}

	@Override
	public int updateStatus(int status, int id) {
		return userDao.updateStatus(status, id);
	}

	@Override
	public User getUserByEmail(String email) {
		return userDao.getUserByEmail(email);
	}

	@Override
	public User getUserById(int id) {
		return userDao.getUserById(id);
	}

	@Override
	public boolean updatePwd(String username, String password) {
		return userDao.updatePwd(username, password)>0;
	}

}
